<?php
/*
 * Joomla! 1.5 component ArticleCashRewards
 *
 * @version $Id: config.php 2009-05-10 01:47:01 svn $
 * @author Maverick
 * @package controllers
 * @subpackage ArticleCashRewards
 * @license GNU/GPL
 * Website: http://www.boddunan.com
 *
 * Review and approve the articles and assign points and cash rewards.
 * Users can see their articles and the points/cash rewards assigned in the front-end module.
*/

defined('_JEXEC') or die();

class ArticleCashRewardsControllerConfig extends ArticleCashRewardsController
{

	function __construct($config = array()){
		parent::__construct($config);
        global $mainframe, $acr_config;
        $acr_config = $mainframe->getUserState( SESSION_ACR_CONFIG );
        if(!isset($acr_config)){
            $model = & $this->getModel('config');
            $configt = $model->getConfiguration();

            foreach($configt as $ct){
                $acr_config[$ct->config_name] = $ct->config_value;
            }
            $mainframe->setUserState( SESSION_ACR_CONFIG, $acr_config );
        }
        $this->registerTask( 'cpanel','cPanel' );
        $this->registerTask( 'save','save' );
        $this->registerTask( 'default','display' );
	}
    
    function display(){

		JRequest::setVar( 'view', 'config' );
		parent::display();
    }

    function save(){
        global $mainframe, $acr_config;
		$model	= &$this->getModel( 'config' );
        if(!$model->saveConfiguration()){
            $msg=$model->getError();
        }
        $configt = $model->getConfiguration();
        foreach($configt as $ct){
            $acr_config[$ct->config_name] = $ct->config_value;
        }
        $mainframe->setUserState( SESSION_ACR_CONFIG, $acr_config );
        //JRequest::setVar( 'view', 'config' );
		//parent::display();
        $link = 'index.php?option=com_articlecashrewards&controller=cpanel';
        $this->setRedirect($link, $msg);
    }

    function cPanel(){
		
        $link = 'index.php?option=com_articlecashrewards&controller=cpanel';
        $this->setRedirect($link);
	}
}
?>
